<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <form action="42-获取URL参数02.html">
        用户名:<input type="text" name="username">
        <input type="submit" value="form传递参数">
    </form>

    <button>js传递参数</button>
</body>
<script>
    var username = document.querySelector('input');
    var bu = document.querySelector('button');
    bu.onclick = function() {
        var url = 'F:/[前端]代码库/JavaScript学习/案例/42-获取URL参数02.html?username=' + username.value;
        location.href = url;
    }
</script>

</html>